﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="newFolder.aspx.cs" Inherits="PeopleRich.PeopleRichWeb.PublicClass.jPlugin.plugin.UploadFileTemplate.source.model.newFolder" %>
<script>

	var newFolder = {

		addFolder: function (obj) {

			var obj = $(obj);

			var input = $('#newFolderInput')

			var val = input.val();

			if (val.length <= 0) {

				$.jLayer.alert({

					background: '#fff',

					subject: '文件夹名不允许为空！'

				});

				return;

			}

			if (val.search(/[!@#$%^&*?;'\\\/]/ig) != -1) {

				$.jLayer.alert({

					background: '#fff',

					subject: '不允许输出特殊字符(! @ # $ % ^ & * ? ; \\ / \')'

				});

				return;

			}

			$.ajax({

				type: 'POST',

				url: this.serverConfig('setFolder'),

				data: 'folderName=' + escape(val) + '&parentID=' + jUploadTemplate.state.parent,

				beforeSend: function () {

					obj.unbind('click');

					input.attr('disabled', true);

				},

				success: function (xmlHttp) {

					if (xmlHttp != 0) {

						$.jLayer.close('#jUploadTemplateNewFolderLayer');

						jUploadTemplate.menu.refresh();

					} else {

						$.jLayer.alert({
						
							background: '#fff',

							subject: '登录超时'

						});

					}

				}

			});

		},

		serverConfig: function (key) {

			return jUploadTemplate.data.config.find('server add[key=' + key + ']').attr('value');

		},

		bind: function () {

			var _this = this;

			$('#newFolderButton').bind('submit',

				function () {

					_this.addFolder(this);

					return false;

				}

			);

		}

	}

	$(document).ready(

		function () {

			newFolder.bind();

		}

	);

</script>

<div class="newFolder">
	<form id="newFolderButton" onsubmit="return false;">
		<table>
			<tr>
				<td width="227" align="right"><input type="text" class="text" style="width:200px;height:23px;line-height:23px;" id="newFolderInput" maxlength="255" /></td>
				<td><a href="javascript:;" class="button" onclick="$('#newFolderButton').submit();">新建文件夹</a></td>
			</tr>
		</table>
	</form>
</div>